﻿using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
namespace LightSwitchApplication
{
    public partial class ManageCustomers
    {
        partial void ClearFilter_Execute()
        {
            // Write your code here.
            this.FirstName = null;
            this.LastName = null;
            this.DOB = null;
        }

        partial void gridAddAndEditNew_CanExecute(ref bool result)
        {
            // Write your code here.
            //result = this.Patients.Count() == 0;
        }

        partial void gridAddAndEditNew_Execute()
        {
            // Write your code here.
            this.Patients.AddAndEditNew();
            if(this.FirstName != null)
                this.Patients.SelectedItem.FirstName = this.FirstName;
            if(this.LastName != null)
                this.Patients.SelectedItem.LastName = this.LastName;
            if (this.DOB.HasValue)
                this.Patients.SelectedItem.DOB = this.DOB.Value;
        }

        partial void gridEditSelected_CanExecute(ref bool result)
        {
            // Write your code here.
            /*if (this.Patients.SelectedItem != null)
                result = this.Patients.SelectedItem.Id == 0;
            else
                result = false;*/
        }

        
        partial void gridEditSelected_Execute()
        {
            // Write your code here.
            this.Patients.EditSelected();
            
        }

        partial void gridDeleteSelected_CanExecute(ref bool result)
        {
            // Write your code here.
            /*if (this.Patients.SelectedItem != null)
                result = this.Patients.SelectedItem.Id == 0;
            else
                result = false;*/
        }

        partial void gridDeleteSelected_Execute()
        {
            // Write your code here.
            this.Patients.DeleteSelected();
        }


    }
}
